#include "field_sorter.h"

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>



struct A {
public:
    const char* id;
    int         count;
    float       weigth;
};

void print(const A& a)
{
    std::cout << "id = " << a.id << " ; count = " << a.count << " ; weigth = " << a.weigth << std::endl;
}

void print(const A* storage, unsigned int size)
{
    for (unsigned int i = 0; i != size; ++i) {
        print(storage[i]);
    }
}


int main(int /*argC*/, char** /*argV*/)
{
    A               storage[]   =   {{"zero", 100, 10.0}, {"one", 10, 9.0}, {"two", 20, 8.0}};
    unsigned int    size        =   sizeof(storage) / sizeof(storage[0]);
    std::cout << "default order : " << std::endl;
    print(storage, size); 
    
    std::cout << "id order : " << std::endl;
    std::sort(storage, storage + size, TFieldSorter<A, const char*>(&A::id));
    print(storage, size);

    std::cout << "count order : " << std::endl;
    std::sort(storage, storage + size, TFieldSorter<A, int>(&A::count));
    print(storage, size);

    std::cout << "weigth order : " << std::endl;
    std::sort(storage, storage + size, TFieldSorter<A, float>(&A::weigth));
    print(storage, size);  
    
}
